﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.EntityValidation
{
    public class ValidResult
    {

       public ValidResult()
        {
            ValidResultDetails = new List<ValidResultDetail>();

        }

        public bool IsValid
        {
            get
            {

                return ValidResultDetails.Count() == 0;
            }
        }
        public virtual string ErrorMessage
        {
            get
            {
                string r = null;

                if (ValidResultDetails.Count() > 0)
                {

                    r = ValidResultDetails.FirstOrDefault().ErrorMessage;
                }

                return r;
            }
            set
            {
                value = ErrorMessage;


            }
        }  //错误摘要
        public List<ValidResultDetail> ValidResultDetails { get; set; }
    }
    public class ValidResultDetail
    {
        public string Name { get; set; }
        public bool IsValid
        {
            get;set;
        }
        public virtual string ErrorMessage { get; set; }
    }
}